home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 85 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.6 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: ark@research.att.com (Andrew Koenig)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: FW: Inherent C++ problem?
  5. Date: 22 Jan 1996 09:37:21 PST
  6. Organization: AT&T Research, Murray Hill NJ
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <DLHn9z.6qC@research.att.com>
  9. References: <01BAE696.8C249300@dino.int.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Sat, 20 Jan 1996 16:32:22 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMQPLYEy4NqrwXLNJAQF0zQH+NZTGvHMV5H9j46lW0fnnw/J2L4WY4ZLc
  14.     LqqgRy8+gZT3obWV+xUtuqe1U8mi06K03piCqIIpOrD9ELCB7wMdqQ==
  15.     =f/iA
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. In article <01BAE696.8C249300@dino.int.com> Eugene Lazutkin <eugene@int.com> writes:
  19.  
  20. >     Complex c( a+b );
  21.  
  22. > In the last line 3 objects of type Complex are constructed instead of 1, 
  23. > namely:
  24.  
  25. > 1) Temporary Complex object constructed in 'operator +'
  26. > 2) Return value of 'operator +' copy-constructed from (1)
  27. > 3) 'c', copy-constructed from (2)
  28.  
  29. > This is inefficient to the last extreme, moreover it cannot even be 
  30. > optimized out since any copy-constructor can theoretically have non-local 
  31. > side effects....
  32.  
  33. But it can be optimized -- essentially the implementation is permitted
  34. to assume that the copy constructor does not have any important
  35. side effects.  Moreover, lots of implementations perform this kind
  36. of optimization.
  37. -- 
  38.                 --Andrew Koenig
  39.                   ark@research.att.com
  40. ---
  41. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  42.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  43.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  44.